home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / fs / fsNameOps.h < prev    next >
C/C++ Source or Header  |  1991-02-01  |  12KB  |  323 lines

  1. /*
  2.  * fsNameOps.h --
  3.  *
  4.  *    Definitions for pathname related operations.  These data structures
  5.  *    define the file system's naming interface.  This is used internally,
  6.  *    for network RPCs, and for the interface to pseudo-file-systems.
  7.  *
  8.  * Copyright 1986 Regents of the University of California
  9.  * All rights reserved.
  10.  *
  11.  *
  12.  * $Header: /sprite/src/kernel/fs/RCS/fsNameOps.h,v 9.4 91/02/01 16:28:51 shirriff Exp $ SPRITE (Berkeley)
  13.  */
  14.  
  15. #ifndef _FSNAMEOPS
  16. #define _FSNAMEOPS
  17.  
  18. /*
  19.  *
  20.  *    There are twp operation switch tables defined here.  (See fsOpTable.c
  21.  *    for their initialization.)
  22.  *    1. The DOMAIN table used for naming operations like OPEN or REMOVE_DIR.
  23.  *        These operations take file names as arguments and have to
  24.  *        be pre-processed by the prefix table module in order to
  25.  *        chose the correct domain type and server.
  26.  *    2. The ATTR table is used when getting/setting attributes when
  27.  *        starting with an open stream (not with a file name).  This
  28.  *        is keyed on the type of the nameFileID in the stream.
  29.  *
  30.  * Name Domain Types:
  31.  *
  32.  *    FS_LOCAL_DOMAIN        The file is stored locally.
  33.  *    FS_REMOTE_SPRITE_DOMAIN    The file is stored on a Sprite server.
  34.  *    FS_PSEUDO_DOMAIN    The file system is implemented by
  35.  *                a user-level server process
  36.  *    FS_NFS_DOMAIN        The file is stored on an NFS server.
  37.  *
  38.  */
  39.  
  40. #define FS_LOCAL_DOMAIN            0
  41. #define FS_REMOTE_SPRITE_DOMAIN        1
  42. #define FS_PSEUDO_DOMAIN        2
  43. #define FS_NFS_DOMAIN            3
  44.  
  45. #define FS_NUM_DOMAINS            4
  46.  
  47. /*
  48.  * DOMAIN SWITCH
  49.  * Domain specific operations that operate on file names for lookup.
  50.  * Naming operations are done through Fsprefix_LookupOperation, which uses
  51.  * the prefix table to choose the domain type and the server for the name.
  52.  * It then branches through the fs_DomainLookup table to complete the operation.
  53.  * The arguments to these operations are documented in fsNameOps.h
  54.  * because they are collected into structs (declared in fsNameOps.h)
  55.  * and passed through Fsprefix_LookupOperation() to domain-specific routines.
  56.  */
  57.  
  58. #define    FS_DOMAIN_IMPORT        0
  59. #define    FS_DOMAIN_EXPORT        1
  60. #define    FS_DOMAIN_OPEN            2
  61. #define    FS_DOMAIN_GET_ATTR        3
  62. #define    FS_DOMAIN_SET_ATTR        4
  63. #define    FS_DOMAIN_MAKE_DEVICE        5
  64. #define    FS_DOMAIN_MAKE_DIR        6
  65. #define    FS_DOMAIN_REMOVE        7
  66. #define    FS_DOMAIN_REMOVE_DIR        8
  67. #define    FS_DOMAIN_RENAME        9
  68. #define    FS_DOMAIN_HARD_LINK        10
  69.  
  70. #define    FS_NUM_NAME_OPS            11
  71.  
  72. extern    ReturnStatus (*fs_DomainLookup[FS_NUM_DOMAINS][FS_NUM_NAME_OPS])();
  73.  
  74. /*
  75.  * ATTRIBUTE SWITCH
  76.  * A switch is used to get to the name server in set/get attributesID,
  77.  * which take an open stream.  The stream refereneces a nameFileID, and
  78.  * this switch is keyed on the nameFileID.type (i.e. local or remote file).
  79.  */
  80.  
  81. #ifdef SOSP91
  82. typedef struct Fs_AttrOps {
  83.     ReturnStatus    (*getAttr) _ARGS_((Fs_FileID *fileIDPtr, int clientID,
  84.                         Fs_Attributes *attrPtr,
  85.                         int hostID, int userID));
  86.  
  87.     ReturnStatus    (*setAttr) _ARGS_((Fs_FileID *fileIDPtr, 
  88.                       Fs_Attributes *attrPtr, 
  89.                       Fs_UserIDs *idPtr, int flags,
  90.                       int clientID, int hostID,
  91.                       int userID));
  92. } Fs_AttrOps;
  93. #else
  94. typedef struct Fs_AttrOps {
  95.     ReturnStatus    (*getAttr) _ARGS_((Fs_FileID *fileIDPtr, int clientID,
  96.                         Fs_Attributes *attrPtr));
  97.  
  98.     ReturnStatus    (*setAttr) _ARGS_((Fs_FileID *fileIDPtr, 
  99.                       Fs_Attributes *attrPtr, 
  100.                       Fs_UserIDs *idPtr, int flags));
  101. } Fs_AttrOps;
  102. #endif
  103.  
  104. extern Fs_AttrOps fs_AttrOpTable[];
  105.  
  106.  
  107. /*
  108.  * The arguments and results of the various lookup operations have to
  109.  * be packaged into a struct so they can be passed through Fsprefix_LookupOperation()
  110.  * and into the domain specific lookup routine.  The following typedefs
  111.  * are for those arguments and results.
  112.  *
  113.  * Pseudo-file-systems:  These structures are also used in the interface
  114.  *    to pseudo-file-system servers.  See <dev/pfs.h>
  115.  */
  116.  
  117. /*
  118.  *     Fs_OpenArgs are used for the DOMAIN_OPEN, DOMAIN_GET_ATTR,
  119.  *    DOMAIN_SET_ATTR, DOMAIN_MAKE_DIR and DOMAIN_MAKE_DEVICE operations.
  120.  *    (Actually, Fs_MakeDeviceArgs & Fs_SetAttrArgs embed Fs_OpenArgs)
  121.  *
  122.  *    The arguments for open specify the starting point of the lookup,
  123.  *    then the root file of the lookup domain, then other parameters
  124.  *    identifying the client and its intended use of the file.
  125.  *
  126.  *    The results of the open fileIDs for the I/O server, the name server,
  127.  *    and the top-level stream to the file.  There is also some data that
  128.  *    is specific to the file type
  129.  *
  130.  */
  131.  
  132. typedef struct Fs_OpenArgs {
  133.     Fs_FileID    prefixID;    /* File ID from prefix handle, MUST BE FIRST */
  134.     Fs_FileID    rootID;        /* File ID of root.  MUST FOLLOW prefix ID.
  135.                  * Used to trap ".." past the root. */
  136.     int        useFlags;    /* Flags defined in fs.h */
  137.     int        permissions;    /* Permission bits for created files.  Already
  138.                  * reflects per-process permission mask */
  139.     int        type;        /* Used to contrain open to a specific type */
  140.     int        clientID;    /* True Host ID of client doing the open */
  141.     int        migClientID;    /* Logical host ID if migrated (the home node)*/
  142.     Fs_UserIDs    id;        /* User and group IDs */
  143. } Fs_OpenArgs;
  144.  
  145. #ifdef SOSP91
  146. typedef struct Fs_OpenArgsSOSP {
  147.     Fs_FileID    prefixID;    /* File ID from prefix handle, MUST BE FIRST */
  148.     Fs_FileID    rootID;        /* File ID of root.  MUST FOLLOW prefix ID.
  149.                  * Used to trap ".." past the root. */
  150.     int        useFlags;    /* Flags defined in fs.h */
  151.     int        permissions;    /* Permission bits for created files.  Already
  152.                  * reflects per-process permission mask */
  153.     int        type;        /* Used to contrain open to a specific type */
  154.     int        clientID;    /* True Host ID of client doing the open */
  155.     int        migClientID;    /* Logical host ID if migrated (the home node)*/
  156.     Fs_UserIDs    id;        /* User and group IDs */
  157.     int        realID;
  158. } Fs_OpenArgsSOSP;
  159. #endif
  160.  
  161. typedef struct Fs_OpenResults {
  162.     Fs_FileID    ioFileID;    /* FileID used to get to I/O server.  This is
  163.                  * set by the name server, although the I/O
  164.                  * server has the right to modify the major
  165.                  * and minor numbers */
  166.     Fs_FileID    streamID;    /* File ID of the stream being opened */
  167.     Fs_FileID    nameID;        /* FileID used to get to the name of the file.*/
  168.     int        dataSize;    /* Size of extra streamData */
  169.     ClientData    streamData;    /* Pointer to stream specific extra data */
  170. } Fs_OpenResults;
  171.  
  172. /*
  173.  * Fs_LookupArgs are used for the DOMAIN_REMOVE and DOMAIN_REMOVE_DIR
  174.  * operations.  Also, Fs_2PathParams embeds Fs_LookupArgs.
  175.  */
  176. typedef struct Fs_LookupArgs {
  177.     Fs_FileID prefixID;    /* FileID of the prefix, MUST BE FIRST */
  178.     Fs_FileID rootID;    /* FileID of the root, MUST FOLLOW prefixID */
  179.     int useFlags;    /* FS_EXECUTE or FS_RENAME */
  180.     Fs_UserIDs id;    /* User and group IDs */
  181.     int clientID;    /* True HostID, needed to expand $MACHINE */
  182.     int migClientID;    /* Logical host ID if migrated (the home node) */
  183. } Fs_LookupArgs;
  184.  
  185. /*
  186.  * FS_DOMAIN_GET_ATTR results.
  187.  */
  188. typedef struct Fs_GetAttrResults {
  189.     Fs_FileID        *fileIDPtr;    /* File ID that indicates I/O server */
  190.     Fs_Attributes    *attrPtr;    /* Returned results */
  191. } Fs_GetAttrResults;
  192.  
  193. /*
  194.  * Rpc storage reply parameter for both redirected and unredirected calls.
  195.  */
  196. typedef    union    Fs_GetAttrResultsParam {
  197.     int    prefixLength;
  198.     struct    AttrResults {
  199.     Fs_FileID    fileID;
  200.     Fs_Attributes    attrs;
  201.     } attrResults;
  202. } Fs_GetAttrResultsParam;
  203.  
  204. /*
  205.  * FS_DOMAIN_SET_ATTR arguments.
  206.  */
  207. typedef struct Fs_SetAttrArgs {
  208.     Fs_OpenArgs        openArgs;
  209.     Fs_Attributes    attr;
  210.     int            flags;    /* Set attr flags defined in user/fs.h */
  211. } Fs_SetAttrArgs;
  212.  
  213. /*
  214.  * FS_DOMAIN_MAKE_DEVICE arguments and results.
  215.  */
  216. typedef struct Fs_MakeDeviceArgs {
  217.     Fs_OpenArgs open;
  218.     Fs_Device device;
  219. } Fs_MakeDeviceArgs;
  220.  
  221. /*
  222.  * FS_DOMAIN_RENAME and FS_DOMAIN_HARD_LINK
  223.  */
  224. typedef struct Fs_2PathParams {
  225.     Fs_LookupArgs    lookup;
  226.     Fs_FileID        prefixID2;
  227. } Fs_2PathParams;
  228.  
  229. typedef struct Fs_2PathData {
  230.     char        path1[FS_MAX_PATH_NAME_LENGTH];
  231.     char        path2[FS_MAX_PATH_NAME_LENGTH];
  232. } Fs_2PathData;
  233.  
  234. typedef struct Fs_2PathReply {
  235.     int        prefixLength;    /* Length of returned prefix on re-direct */
  236.     Boolean    name1ErrorP;    /* TRUE if the error returned, which is either
  237.                  * a re-direct or stale-handle, applies to
  238.                  * the first of the two pathnames, FALSE if
  239.                  * it applies to the second pathname */
  240. } Fs_2PathReply;
  241.  
  242. /*
  243.  * All pathname operations may potentially return new prefix information
  244.  * from the server, or redirected lookups.
  245.  */
  246. typedef struct Fs_RedirectInfo {
  247.     int    prefixLength;        /* The length of the prefix embedded in
  248.                  * fileName.  This is used when a server hits
  249.                  * a remote link and has to return a new file
  250.                  * name plus an indication of a new prefix. */
  251.     char fileName[FS_MAX_PATH_NAME_LENGTH];    /* A new file name.  Returned
  252.                  * from the server when its lookup is about
  253.                  * to leave its domain. */
  254. } Fs_RedirectInfo;
  255.  
  256. typedef struct Fs_2PathRedirectInfo {
  257.     int name1ErrorP;        /* TRUE if redirection or other error applies
  258.                  * to the first pathname, FALSE if the error
  259.                  * applies to second pathname, or no error */
  260.     int    prefixLength;        /* The length of the prefix embedded in
  261.                  * fileName.  This is used when a server hits
  262.                  * a remote link and has to return a new file
  263.                  * name plus an indication of a new prefix. */
  264.     char fileName[FS_MAX_PATH_NAME_LENGTH];    /* A new file name.  Returned
  265.                  * from the server when its lookup is about
  266.                  * to leave its domain. */
  267. } Fs_2PathRedirectInfo;
  268.  
  269.  
  270. /*
  271.  * Table of name lookup routine maintained by each domain type.
  272.  */
  273. typedef struct Fs_DomainLookupOps {
  274.      ReturnStatus (*import) _ARGS_((char *prefix, int serverID, 
  275.             Fs_UserIDs *idPtr, int *domainTypePtr,
  276.             Fs_HandleHeader **hdrPtrPtr));
  277.      ReturnStatus (*export) _ARGS_((Fs_HandleHeader *hdrPtr, int clientID,
  278.             Fs_FileID *ioFileIDPtr, int *dataSizePtr, 
  279.             ClientData *clientDataPtr));
  280.      ReturnStatus (*open) _ARGS_((Fs_HandleHeader *prefixHandlePtr,
  281.             char *relativeName, Address argsPtr, Address resultsPtr, 
  282.             Fs_RedirectInfo **newNameInfoPtrPtr));
  283.      ReturnStatus (*getAttrPath) _ARGS_((Fs_HandleHeader *prefixHandlePtr,
  284.             char *relativeName, Address argsPtr, Address resultsPtr,
  285.             Fs_RedirectInfo **newNameInfoPtrPtr));
  286.      ReturnStatus (*setAttrPath) _ARGS_((Fs_HandleHeader *prefixHandlePtr,
  287.             char *relativeName, Address argsPtr, Address resultsPtr,
  288.             Fs_RedirectInfo **newNameInfoPtrPtr));
  289.      ReturnStatus (*makeDevice) _ARGS_((Fs_HandleHeader *prefixHandle, 
  290.             char *relativeName, Address argsPtr, Address resultsPtr,
  291.             Fs_RedirectInfo **newNameInfoPtrPtr));
  292.      ReturnStatus (*makeDir) _ARGS_((Fs_HandleHeader *prefixHandle, 
  293.             char *relativeName, Address argsPtr, Address resultsPtr, 
  294.             Fs_RedirectInfo **newNameInfoPtrPtr));
  295.      ReturnStatus (*remove) _ARGS_((Fs_HandleHeader *prefixHandle, 
  296.             char *relativeName, Address argsPtr, Address resultsPtr, 
  297.             Fs_RedirectInfo **newNameInfoPtrPtr));
  298.      ReturnStatus (*removeDir) _ARGS_((Fs_HandleHeader *prefixHandle, 
  299.             char *relativeName, Address argsPtr, Address resultsPtr, 
  300.             Fs_RedirectInfo **newNameInfoPtrPtr));
  301.      ReturnStatus (*rename) _ARGS_((Fs_HandleHeader *prefixHandle1, 
  302.             char *relativeName1, Fs_HandleHeader *prefixHandle2, 
  303.             char *relativeName2, Fs_LookupArgs *lookupArgsPtr, 
  304.             Fs_RedirectInfo **newNameInfoPtrPtr, 
  305.             Boolean *name1ErrorPtr));
  306.      ReturnStatus (*hardLink) _ARGS_((Fs_HandleHeader *prefixHandle1, 
  307.             char *relativeName1, Fs_HandleHeader *prefixHandle2,
  308.             char *relativeName2, Fs_LookupArgs *lookupArgsPtr, 
  309.             Fs_RedirectInfo **newNameInfoPtrPtr, 
  310.             Boolean *name1ErrorPtr));
  311. } Fs_DomainLookupOps;
  312.  
  313.  
  314. /*
  315.  * Forward references.
  316.  */
  317. extern void Fs_SetIDs _ARGS_((Proc_ControlBlock *procPtr, Fs_UserIDs *idPtr));
  318. extern void Fs_InstallDomainLookupOps _ARGS_((int domainType, 
  319.         Fs_DomainLookupOps *nameLookupOpsPtr, 
  320.         Fs_AttrOps *attrOpTablePtr));
  321.  
  322. #endif _FSNAMEOPS
  323.